package StudyCode.summary.mycollection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ShallowCopyOfTheGivenCollection {
	public static <T> List<T> shallowCopyWithoutNulls(Collection<T> srcList) {
		if (srcList == null) {
			return new ArrayList<T>();
		}

		List<T> copy = new ArrayList<T>(srcList.size());
		for (T t : srcList) {
			if (t != null) {
				copy.add(t);
			}
		}

		return copy;
	}
}
